home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / Onboard / KeyGtk.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  6.6 KB  |  156 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import pango
  5. from KeyCommon import *
  6.  
  7. class Key(KeyCommon):
  8.     
  9.     def __init__(self, pane):
  10.         KeyCommon.__init__(self, pane)
  11.  
  12.     
  13.     def moveObject(self, x, y, context = None):
  14.         context.move_to(x, y)
  15.  
  16.     
  17.     def createLayout(self, label):
  18.         self.layout = self.pane.keyboard.create_pango_layout(label)
  19.  
  20.     
  21.     def paintFont(self, xScale, yScale, x, y, context = None):
  22.         KeyCommon.paintFont(self, xScale, yScale, x, y, context)
  23.         if hasattr(self, 'layout'):
  24.             context.set_source_rgb(0, 0, 0)
  25.             self.layout.set_font_description(pango.FontDescription('Sans Serif %d' % self.fontScale * self.pane.fontSize))
  26.             context.update_layout(self.layout)
  27.             context.show_layout(self.layout)
  28.         
  29.  
  30.  
  31.  
  32. class TabKey(TabKeyCommon, Key):
  33.     
  34.     def __init__(self, keyboard, width, pane):
  35.         TabKeyCommon.__init__(self, keyboard, width, pane)
  36.         Key.__init__(self, pane)
  37.  
  38.     
  39.     def paint(self, context = None):
  40.         TabKeyCommon.paint(self, context)
  41.         context.rectangle(self.keyboard.kbwidth, self.height * self.index + BASE_PANE_TAB_HEIGHT, self.width, self.height)
  42.         if self.pane == self.keyboard.activePane and self.stuckOn:
  43.             context.set_source_rgba(1, 0, 0, 1)
  44.         else:
  45.             context.set_source_rgba(float(self.pane.rgba[0]), float(self.pane.rgba[1]), float(self.pane.rgba[2]), float(self.pane.rgba[3]))
  46.         context.fill()
  47.  
  48.  
  49.  
  50. class BaseTabKey(BaseTabKeyCommon, Key):
  51.     
  52.     def __init__(self, keyboard, width):
  53.         BaseTabKeyCommon.__init__(self, keyboard, width)
  54.         Key.__init__(self, None)
  55.  
  56.     
  57.     def paint(self, context):
  58.         pass
  59.  
  60.  
  61.  
  62. class LineKey(LineKeyCommon, Key):
  63.     
  64.     def __init__(self, pane, coordList, fontCoord, rgba):
  65.         LineKeyCommon.__init__(self, pane, coordList, fontCoord, rgba)
  66.         Key.__init__(self, pane)
  67.  
  68.     
  69.     def pointWithinKey(self, widget, mouseX, mouseY):
  70.         '''Cairo specific, hopefully fast way of doing this'''
  71.         context = widget.window.cairo_create()
  72.         self.draw_path(self.pane.xScale, self.pane.yScale, context)
  73.         return context.in_fill(mouseX, mouseY)
  74.  
  75.     
  76.     def paint(self, xScale, yScale, context):
  77.         self.draw_path(xScale, yScale, context)
  78.         if self.stuckOn:
  79.             context.set_source_rgba(1, 0, 0, 1)
  80.         elif self.on:
  81.             context.set_source_rgba(0.5, 0.5, 0.5, 1)
  82.         elif self.beingScanned:
  83.             context.set_source_rgba(0.45, 0.45, 0.7, 1)
  84.         else:
  85.             context.set_source_rgba(self.rgba[0], self.rgba[1], self.rgba[2], self.rgba[3])
  86.         context.fill_preserve()
  87.         context.set_source_rgb(0, 0, 0)
  88.         context.stroke()
  89.  
  90.     
  91.     def draw_path(self, xScale, yScale, context):
  92.         ''' currently this method contains all the LineKey 
  93.             painting code.\xc2\xa0'''
  94.         LineKeyCommon.paint(self, xScale, yScale, context = None)
  95.         c = 2
  96.         context.move_to(self.coordList[0] * xScale, self.coordList[1] * yScale)
  97.         while not c == len(self.coordList):
  98.             xp1 = self.coordList[c + 1] * xScale
  99.             yp1 = self.coordList[c + 2] * yScale
  100.             
  101.             try:
  102.                 if self.coordList[c] == 'L':
  103.                     c += 3
  104.                     context.line_to(xp1, yp1)
  105.                 else:
  106.                     xp2 = self.coordList[c + 3] * xScale
  107.                     yp2 = self.coordList[c + 4] * yScale
  108.                     xp3 = self.coordList[c + 5] * xScale
  109.                     yp3 = self.coordList[c + 6] * yScale
  110.                     context.curve_to(xp1, yp1, xp2, yp2, xp3, yp3)
  111.                     c += 7
  112.             continue
  113.             except TypeError:
  114.                 strerror = None
  115.                 print x
  116.                 print y
  117.                 print xp1
  118.                 print yp1
  119.                 print strerror
  120.                 continue
  121.             
  122.  
  123.             None<EXCEPTION MATCH>TypeError
  124.  
  125.     
  126.     def paintFont(self, xScale, yScale, context = None):
  127.         Key.paintFont(self, xScale, yScale, self.fontCoord[0], self.fontCoord[1], context)
  128.  
  129.  
  130.  
  131. class RectKey(RectKeyCommon, Key):
  132.     
  133.     def __init__(self, pane, x, y, width, height, rgba):
  134.         RectKeyCommon.__init__(self, pane, x, y, width, height, rgba)
  135.  
  136.     
  137.     def paint(self, xScale, yScale, context = None):
  138.         context.rectangle(self.x * xScale, self.y * yScale, self.width * xScale, self.height * yScale)
  139.         if self.stuckOn:
  140.             context.set_source_rgba(1, 0, 0, 1)
  141.         elif self.on:
  142.             context.set_source_rgba(0.5, 0.5, 0.5, 1)
  143.         elif self.beingScanned:
  144.             context.set_source_rgba(0.45, 0.45, 0.7, 1)
  145.         else:
  146.             context.set_source_rgba(self.rgba[0], self.rgba[1], self.rgba[2], self.rgba[3])
  147.         context.fill_preserve()
  148.         context.set_source_rgb(0, 0, 0)
  149.         context.stroke()
  150.  
  151.     
  152.     def paintFont(self, xScale, yScale, context = None):
  153.         Key.paintFont(self, xScale, yScale, self.x, self.y, context)
  154.  
  155.  
  156.